package com.example.testapplication.binding.lottieAnimationView;

import android.animation.Animator;

import androidx.databinding.BindingAdapter;

import com.airbnb.lottie.LottieAnimationView;

import me.goldze.mvvmhabit.binding.command.BindingCommand;

public class ViewAdapter {
    @BindingAdapter(value = "onAnimationEndCommand")
    public static void onAnimationCommand(LottieAnimationView view, final BindingCommand onAnimationEndCommand){
        view.addAnimatorListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {

            }

            @Override
            public void onAnimationEnd(Animator animation) {
                if(onAnimationEndCommand !=null){
                    onAnimationEndCommand.execute();
                }
            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });
    }
}
